// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.TextStructure;

public sealed partial class TestGrokPatternRequestParameters : RequestParameters
{
	/// <summary>
	/// <para>The mode of compatibility with ECS compliant Grok patterns (disabled or v1, default: disabled).</para>
	/// </summary>
	public string? EcsCompatibility { get => Q<string?>("ecs_compatibility"); set => Q("ecs_compatibility", value); }
}

/// <summary>
/// <para>Tests a Grok pattern on some text.</para>
/// </summary>
public sealed partial class TestGrokPatternRequest : PlainRequest<TestGrokPatternRequestParameters>
{
	internal override ApiUrls ApiUrls => ApiUrlLookup.TextStructureTestGrokPattern;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "text_structure.test_grok_pattern";

	/// <summary>
	/// <para>The mode of compatibility with ECS compliant Grok patterns (disabled or v1, default: disabled).</para>
	/// </summary>
	[JsonIgnore]
	public string? EcsCompatibility { get => Q<string?>("ecs_compatibility"); set => Q("ecs_compatibility", value); }

	/// <summary>
	/// <para>Grok pattern to run on the text.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("grok_pattern")]
	public string GrokPattern { get; set; }

	/// <summary>
	/// <para>Lines of text to run the Grok pattern on.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("text")]
	public ICollection<string> Text { get; set; }
}

/// <summary>
/// <para>Tests a Grok pattern on some text.</para>
/// </summary>
public sealed partial class TestGrokPatternRequestDescriptor : RequestDescriptor<TestGrokPatternRequestDescriptor, TestGrokPatternRequestParameters>
{
	internal TestGrokPatternRequestDescriptor(Action<TestGrokPatternRequestDescriptor> configure) => configure.Invoke(this);

	public TestGrokPatternRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.TextStructureTestGrokPattern;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "text_structure.test_grok_pattern";

	public TestGrokPatternRequestDescriptor EcsCompatibility(string? ecsCompatibility) => Qs("ecs_compatibility", ecsCompatibility);

	private string GrokPatternValue { get; set; }
	private ICollection<string> TextValue { get; set; }

	/// <summary>
	/// <para>Grok pattern to run on the text.</para>
	/// </summary>
	public TestGrokPatternRequestDescriptor GrokPattern(string grokPattern)
	{
		GrokPatternValue = grokPattern;
		return Self;
	}

	/// <summary>
	/// <para>Lines of text to run the Grok pattern on.</para>
	/// </summary>
	public TestGrokPatternRequestDescriptor Text(ICollection<string> text)
	{
		TextValue = text;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("grok_pattern");
		writer.WriteStringValue(GrokPatternValue);
		writer.WritePropertyName("text");
		JsonSerializer.Serialize(writer, TextValue, options);
		writer.WriteEndObject();
	}
}